package com.zr.dao;

import com.zr.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserDao {
    @Insert("insert into ev_users(username, password, nickname, email, user_pic) " +
            "values(#{username}, #{password}, #{nickname}, #{email}, #{user_pic})")
    int insert(User user);

    @Select("select * from ev_users where username = #{username}")
    User selectByUsername(String username);

    @Update("update ev_users set username = #{username}, nickname = #{nickname}, email = #{email} where id = #{id}")
    int updateUser(User user);

    @Update("update ev_users set password = #{newPwd} where username = #{username}")
    int updateUserPwd(@Param("newPwd") String newPwd, @Param("username") String username);

//    TODO 头像功能已做--实现方式：base64将二进制文件转换成字符串存储到数据库
    @Update("update ev_users set user_pic = #{user_pic} where username = #{username}")
    int upadateUserPic(@Param("user_pic") String user_pic, @Param("username") String username);
}
